package com.genreate.util.pay.wx.enums;

/**
 * wx支付状态
 *
 * @author LYS
 * @date 2025-07-12
 */
public enum WxPayStatus {
    SUCCESS("SUCCESS", "支付成功"),
    REFUND("REFUND", "转入退款"),
    NOTPAY("NOTPAY", "未支付"),
    CLOSED("CLOSED", "已关闭"),
    REVOKED("REVOKED", "已撤销（仅付款码支付会返回）"),
    USERPAYING("USERPAYING", "用户支付中（仅付款码支付会返回）"),
    PAYERROR("PAYERROR", "支付失败（仅付款码支付会返回）");

    private final String code;
    private final String description;

    WxPayStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    // Getters
    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }


    // 根据状态码获取枚举
    public static WxPayStatus fromCode(String code) {
        for (WxPayStatus status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的支付状态码: " + code);
    }
}    